<?php
/**
 * Created by PhpStorm.
 * User: wangjie
 * Date: 2018/11/8
 * Time: 10:31
 */

namespace common\services;

use common\services\config\Config;
use common\services\tool\ToolString;

class ToolStringService
{
    /**
     * 查看字符长度
     * @param $str
     * @return mixed
     */
    public static function strLen($str)
    {
        $result['english'] = ToolString::strLen($str);
        $result['china'] = ToolString::strLenMb($str);
        return $result;
    }

    /**
     * 基础项认证
     * @param $str
     * @return mixed
     */
    public static function detectionStr($str)
    {
        $result['is_email'] = ToolString::isEmail($str);
        $result['is_ip'] = ToolString::isIP($str);
        $result['is_url'] = ToolString::isURL($str);
        $result['is_telephone'] = ToolString::isTelephone($str);
        return $result;
    }

    /**
     * 字符串转义
     * @param $str
     * @return mixed
     */
    public static function strConversion($str)
    {
        $result['letter_hump'] = ToolString::camelCase($str);
        $result['each_hump'] = ToolString::camelCaseWithUcFirst($str);
        $result['lowercase'] = strtolower(ToolString::camelCase($str));
        $result['capital'] = strtoupper(ToolString::camelCase($str));
        return $result;
    }

    /**
     * 根据需求设计长度随机字符串
     * @param $num
     * @param $type
     * @return string
     */
    public static function randomStr($num, $type)
    {
        $result['str'] = ToolString::randomNum($num, $type);;
        return $result;
    }

    /**
     * 判断字符串长度
     * @param $str
     * @return int
     */
    public static function mbStr($str)
    {
        $result = ToolString::mbStr($str);
        return $result;
    }
}